//
//  PHVisitorViewController.swift
//  PHWeibo
//
//  Created by 潘荟 on 16/7/19.
//  Copyright © 2016年 BAT. All rights reserved.
//

import UIKit

class PHVisitorViewController: UIViewController {
    
    var isLogin:Bool = PHUserAccountView.sharedTools.isLogin
    var visitorView:PHVisitorView?
    
    override func loadView() {
        
        isLogin ? (view = tableView) : setupVisitorView()
    }
    
    //设置方可视图
    func setupVisitorView() {
        visitorView = PHVisitorView()
        view = visitorView
        
        //实现闭包
        visitorView?.closure = {[weak self] in
            self?.loginClick()
        }
         setupNav()
    }
    
    //添加监听方法
    func loginClick() {
        let oauthVC = PHOAuthViewController()
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
    
    func setupNav() {

        navigationItem.leftBarButtonItem = PHBarButtonItem(title: "登陆", imgName: nil, target: self, action: "loginClick")
        
        navigationItem.rightBarButtonItem = PHBarButtonItem(title: "注册", target: self, action: "loginClick")
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()

        
    }
    
    //懒加载控件-tableView
    lazy var tableView:UITableView = UITableView()


}








